package com.blog.service;

import com.blog.mapper.SecAddressMapper;
import com.blog.properties.GaoDeProperties;
import com.blog.seckill.address.SecAddress;
import com.blog.util.gaode.GaoDeInit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName SecAddressService
 * @Destription  整合高德地图
 * @Author 天堂小野花
 * @Date 2025/7/21  14:52
 * @Version 1.0
 */
@Service
public class SecAddressService {

    @Autowired
    SecAddressMapper secAddressMapper;
    @Autowired
    GaoDeProperties gaoDeProperties;
    public List<SecAddress> initSecAddress() {
        return secAddressMapper.initSecAddress();
    }

    public List<Map<Integer, String>> initSecBusi() {
        return secAddressMapper.initSecBusi();
    }

    public List<Map<Integer, String>> initSecState() {
        return secAddressMapper.initSecState();
    }

    public int addAddress(SecAddress secAddress) {

        return secAddressMapper.insertSelective(secAddress);
    }

    public int saveAddress(SecAddress secAddress) {
        return secAddressMapper.updateByPrimaryKeySelective(secAddress);
    }

    public void initGod() {
        GaoDeInit gaoDeInit = new GaoDeInit();
        String address ="北京市朝阳区阜通东大街6号";
        String result = gaoDeInit.initGod(gaoDeProperties.getGeoCodeUrl(),address,gaoDeProperties.getKey());
        System.out.println(result);
    }
}
